package com.ag.dgm.service.impl;

import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import com.ag.bean.TbAdviceType;
import com.ag.common.AgException;
import com.ag.common.IDServiceImpl;
import com.ag.common.IDUtil;
import com.ag.dgm.dao.TbAdviceTypeDAO;
import com.ag.dgm.service.IAdviceTypeService;

@Service("adviceTypeServiceImpl")
public class AdviceTypeServiceImpl implements IAdviceTypeService{

	@Resource(name="iDServiceImpl")
	private IDServiceImpl idService;
	
	@Resource(name="DGMtbAdviceTypeDAO")
	private TbAdviceTypeDAO dao;
	
	@Override
	public void add(TbAdviceType tbAdviceType) {
		String IDs = null;
		try {
			IDs = idService.findTablePK(IDUtil.TB_ADVICE_TYPE);
		} catch (AgException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		tbAdviceType.setAtId(IDs);
		dao.save(tbAdviceType);
		
	}

	@Override
	public void delete(TbAdviceType tbAdviceType) {
		dao.delete(tbAdviceType);
		
	}

	@Override
	public List<TbAdviceType> findAll() {
		
		return dao.findAll();
	}

	@Override
	public void modify(TbAdviceType tbAdviceType) {
		tbAdviceType.setA(IDUtil.PRESERVE);
		dao.attachDirty(tbAdviceType);
		
	}

}
